package com.study.practice.utils.regex;

import java.util.Scanner;

public class IPRegex {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String ip = in.next();
            System.out.println(ip.matches(new MyRegex().pattern));
        }
    }
}

class MyRegex{
    public String pattern = "(([0-2][0-5]{0,2}\\.){3}[0-2][0-5]{0,2})||(([0-9]{1,2}\\.){3}[0-9]{1,2})" +
            "||(([0-2][0-4]?[0-9]?\\.){3}[0-2][0-4]?[0-9])";
}